$(function () {
    $("#login").click(function () {
        let username = $('#username').val()
        let password = $('#password').val()
        if ( username ==='' || password ==='') {
            layer.msg('请输入账号和密码', { icon: 5 })
            return
        }
        $.ajax({
            url: '/admin/user/login',
            type: 'post',
            data: { username, password },
            success(res) {
                if (res.code == 200) {
                    localStorage.setItem('token', res.token)
                    location.href='index.html'
                }
            }
        })
    })
})
